package com.dcjt.firehotcarpad.utils;

import android.content.Context;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;

import static android.content.Context.INPUT_METHOD_SERVICE;

public class InputSoftUtils {
    /**
     * 显示键盘
     *
     * @param et 输入焦点
     */
    public static void showInput( EditText et, Context mcontext) {
        et.requestFocus();
        InputMethodManager imm = (InputMethodManager) mcontext.getSystemService(INPUT_METHOD_SERVICE);
        imm.showSoftInput(et, InputMethodManager.SHOW_IMPLICIT);
    }

    /**
     * 隐藏键盘
     */
    public static void hideInput(Context context,EditText et) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);

        if (null != et) {
            imm.hideSoftInputFromWindow(et.getWindowToken(), 0);
        }
    }
}
